/*
 * Copyright 2008,2009,2010 Daniel Freitas
 *
 * This file is part of DMF Generic DAO.
 *
 * DMF Generic DAO is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
 * Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * DMF Generic DAO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with DMF Generic DAO. If not, see
 * <http://www.gnu.org/licenses/>.
 */
package com.googlecode.dmf.genericdao;

import java.lang.reflect.Method;

/**
 * An {@link QueryNameResolver} which retrieves the query name from the method name. The method name will be calculated
 * as the fully qualified class name plus the method name. For example:
 * <tt>com.googlecode.genericdao.SampleDao.findByName</tt>.
 * <p/>
 * Note that this resolver does not take the parameter list into account, just the method name. That means that
 * overloading methods will always resolve to the same query name.
 *
 * @author <a href="mailto:daniel.mfreitas@gmail.com">Daniel Freitas</a>
 */
public class MethodNameQueryNameResolver implements QueryNameResolver {

    /**
     * {@inheritDoc}
     *
     * @see com.googlecode.dmf.genericdao.QueryNameResolver#resolveName(java.lang.reflect.Method)
     */
    public String resolveName(final Method targetMethod) {
        String queryName = targetMethod.getDeclaringClass().getName() + "." + targetMethod.getName();

        return queryName;
    }
}
